home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
001a
/
myhost.zip
/
MYHOST.ASP
< prev
next >
Wrap
Text File
|
1991-07-08
|
62KB
|
1,995 lines
; MYHOST - a mini BBS for Procomm Plus
; greatly modified version of HOST by DataStorm
; Perry Brickley 07/05/91
;**************************************************************************
;# - - - - - - - - - - - - SECTIONS IN FILE - - - - - - - - - - - - - #
;# #
;# A. User defines #
;# B. Internal defines #
;# C. Global data #
;# D. MAIN #
;# E. Setup routines #
;# F. Callback routines #
;# G. High level I/O routines #
;# H. Miscellaneous routines #
;# I. Debug routines #
;# #
;# #
;##########################################################################
;##########################################################################
;# #
;# ╔═══╗ #
;# ║ A.║ USER defines #
;# ╚═══╝ #
;# #
;##########################################################################
;define DEBUG ; Uncomment for debugging
;--------------------------------------------------------------------
define BLACK 0
define BLUE 1
define GREEN 2
define CYAN 3
define RED 4
define MAGENTA 5
define BROWN 6
define LTGREY 7
define GREY 8
define LTBLUE 9
define LTGREEN 10
define LTCYAN 11
define LTRED 12
define LTMAGENTA 13
define YELLOW 14
define WHITE 15
define UNDERLINE 1
define LTULINE 9
define NOBLINK 0
define BLINK 128
;***********************************************************************
;* Below are the definitions for Boolean variables and special *
;* keys. *
;* *
;***********************************************************************
define TRUE 1
define FALSE 0
define F1 0x3B00
define F2 0x3C00
define F3 0x3D00
define F4 0x3E00
define F5 0x3F00
define F6 0x4000
define F7 0x4100
define F8 0x4200
define F9 0x4300
define F10 0x4400
define F11 0x8500
define F12 0x8600
define HOME_KEY 0x4700
define END 0x4F00
define PG_UP 0x4900
define PG_DN 0x5100
define INS 0x5200
define DEL 0x5300
define CUR_LT 0x4B00
define CUR_RT 0x4D00
define CUR_DN 0x5000
define CUR_UP 0x4800
define ALT_Z 0x2C00
define PROCOMMDIR "C:\PCOM" ; my procomm directory
define HOSTUSRFILE "C:\PCOM\PCPLUS.USR" ; User data file
define HOSTDLDIR "C:\ARC\" ; Host user accessable files
define HOSTULDIR "C:\ARC\" ; Where files uploaded to host go
define HOSTWELCOM "" ; String to send as user connects
define HOSTPORT COM2 ; (COM1-COM8) COM port to use.
define HOSTBAUD 2400 ; (300-115200) Highest baud rate.
define HOSTCALLOG ON ; (ON | OFF) Log callbacks?
define HOSTCDXFER YES ; (YES | NO) Monitor CD during transfers?
define HOSTUSEDTR YES ; (YES | NO) Use DTR to hangup?
define HOSTHFLOW OFF ; (ON | OFF)
define HOSTSFLOW OFF ; (ON | OFF)
define HOSTAUTOBD ON ; (ON | OFF) Automatically adjust baud rate?
define HOSTCONTYP MODEM ; (MODEM | DIRECT) Using a modem or a cable?
define HOSTMAXDIAL 3 ; (0-999) Number of times to try callback.
define HOSTNEWUSR 0 ; (0 | 1) Let new users transfer files?
define HOSTREMCMD OFF ; (ON | OFF) Allow remote commands?
define HOSTSYSTYP CLOSED; (OPEN | CLOSED) Should system allow new users?
define HOSTSHELCD ON ; (ON | OFF) Monitor CD during Shell?
define HOSTTIMOUT 5 ; (0-999) Minutes inactive before hangup.
;--------------------------------------------------------------------
;##########################################################################
;# #
;# ╔═══╗ #
;# ║ B.║ INTERNAL DEFINES #
;# ╚═══╝ #
;# #
;##########################################################################
;define FALSE 0
;define TRUE 1
define NAMEMAX 30
define PSWDMAX 8
define DISP 1
define HIDE 0
define FLD_SEP 59 ; semi-colon ; Field separator
define BOXMSG call _BoxMsg with
define BOXVARI call _BoxVarI with
define BOXVARS call _BoxVarS with
define COPYSFLD call _CopySFld with
define HOSTGETC call _HostGetC with
define HOSTGETS call _HostGetS with
define HOSTGETYN call _HostGetYN
define HOSTGOODBYE call _HostGoodbye
define HOSTHANGUP call _HostHangup
define HOSTPUTS call _HostPutS with
define QPAUSE call _QPause
define SETFAILURE call _SetFailure
define SETSUCCESS call _SetSuccess
define XKEYGET call _XKeyGet with
define TX transmit
define setvattr call mkvattr with
define NEWLINE call _newline
define HOSTCLS call _hostcls
;##########################################################################
;# #
;# ╔═══╗ #
;# ║ C.║ GLOBAL DATA #
;# ╚═══╝ #
;# #
;##########################################################################
string urec,ufirst,ulast,upassword,ucomment,ulevel
string cbnumber, savnum
string mailfrom, maildate, mailfile
string prefix = "70#," ; cancel call waiting for callback
; set to "" for no prefix
integer escok=0 ; enable or disable host exit
integer chatdir=0 ; chat mode direction
;##########################################################################
;# #
;# ╔═══╗ #
;# ║ D.║ MAIN #
;# ╚═══╝ #
;# #
;##########################################################################
proc main
call setup ; Setup port, modem, and variables
while forever ;---- TOP OF loop
if not connected && N9 != F2 ; coming in first time
HOSTCLS
N8 = 0 ; call back flag
call GetUser ; Wait for someone to login
else
SETSUCCESS ; a return from another script
endif
if success ; If user logged on,
call domystuff ; my routines
HOSTGOODBYE
HOSTCLS
TX "ATS0=1^M"
N9 = 0
else ; else ESC key pressed from user wait
exitwhile ;
endif ;
endwhile
endproc
;##########################################################################
;# #
;# ╔═══╗ #
;# ║ E.║ SETUP ROUTINES #
;# ╚═══╝ #
;# #
;# (1) Setup #
;# (2) SetupPort #
;# (3) SetupVars #
;# (4) SetupModem #
;# #
;##########################################################################
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: Setup
;*
;* Purpose: Initialize procOMM PLUS 2.0 for use as a BBS
;*
;* Input: None
;*
;* Return: None
;*
;* Preconditions: None
;*
;* Postconditions: The port, modem, and variables are initialized.
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc setup
; call SetupPort ; Not needed - procomm does this
call SetupVars
; call SetupModem ; dito
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: SetupPort
;*
;* Purpose: Initialize the communications port
;*
;* Input: None
;*
;* Return: None
;*
;* Preconditions: None
;*
;* Postconditions: The port baud rate and line settings are initialized.
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc SetupPort
set port hostport
set baud hostbaud
set parity none
set databits 8
set stopbits 1
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: SetupVars
;*
;* Purpose: Initialize sytem variables
;*
;* Input: None
;*
;* Return: None
;*
;* Preconditions: None
;*
;* Postconditions: System variables are inialized.
;*
;* Notes: Many variables are considered to be 'permanent'.
;* Consequently, they are assumed to be setup correctly
;* and are not set again here. For example, the modem
;* command strings, the modem connect strings, and the
;* options related to dialing must all be configured
;* permanently before running this script.
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc SetupVars
set host autobaud HOSTAUTOBD ; Setup host variables using their
set host connection HOSTCONTYP ; definitions at the top of this file
set host dldir HOSTDLDIR
set host message HOSTWELCOM
set host newuserlvl HOSTNEWUSR
set host systype HOSTSYSTYP
set host timeout HOSTTIMOUT
set host uldir HOSTULDIR
set host shellboot HOSTSHELCD
set callog HOSTCALLOG ; Setup miscellaneous variables using
set cdinxfer HOSTCDXFER ; their definitions at the top
set dropdtr HOSTUSEDTR
set hardflow HOSTHFLOW
set modem maxdial HOSTMAXDIAL
set remotecmd HOSTREMCMD
set softflow HOSTSFLOW
set host goodbye recycle
set fgets_crlf off
$ifdef DEBUG ; set some variables if debugging:
set aspdebug on ; Put offsets in error messages
set rangechk on ; Perform range checking
$endif
set keys on ; We do all keys
set rxdata on ; We do all incoming data
set kermit blockcheck 3 ; Use "3 byte CRC"
set kermit filetype binary ; Use binary kermit
set kermit packsize 1024 ; Negotiate up to maximum packet size
set zmodem errdetect crc32 ; Use 32-bit CRC
set zmodem recvcrash protect ; Don't let users overwrite files
set zmodem sendcrash negotiate ; Let user recover his downloads
set zmodem timestamp off ; Stamp files with system date/time
set zmodem txmethod streaming ; Use fastest transmit method
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: SetupModem
;*
;* Purpose: Initialize the modem for use as a host answerer
;*
;* Input: None
;*
;* Return: None
;*
;* Preconditions: The port is setup to communicate with the modem
;*
;* Postconditions: The modem is ready to be used by host mode.
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc SetupModem
integer i, savetxpace
fetch txpace savetxpace
fetch termnorm i
set txpace 150
atsay 0 0 i "Initializing MODEM."
locate 0 19
TX "ATS7=255^M"
QPAUSE
TX "ATV1^M~"
QPAUSE
TX "ATQ0^M~"
QPAUSE
TX "ATS11=55^M"
QPAUSE
TX "ATX4^M"
QPAUSE
TX "ATM0^M"
QPAUSE
; TX "ATS0=1^M"
; QPAUSE
HOSTCLS
; ...
; ...
; ... (Insert other modem settings here)
; ...
; ...
set txpace savetxpace
endproc
;##########################################################################
;# #
;# ╔═══╗ #
;# ║ F.║ CALLBACK ROUTINES #
;# ╚═══╝ #
;# #
;# (1) CallBack #
;# (2) CallBackRights #
;# (3) WantsCB #
;# #
;##########################################################################
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: CallBack
;*
;* Purpose: hangup and dial the callback number.
;*
;* Input: ('cbnumber' contains the number to dial)
;*
;* Return: Nothing
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc CallBack
string title,usernumber
if connected
HOSTPUTS "`r`n`r`n hangup now and make sure your modem is set to answer."
HOSTPUTS "`r`n You will be called back momentarily....`r`n`r`n"
HOSTHANGUP
if connected
return
endif
endif
strcpy usernumber prefix ; get prefix for dialing (i.e. 70#,)
strcat usernumber cbnumber
pause 5
strfmt title "Calling: %s" S9
mdial usernumber title
if connected
pause 1
rflush
endif
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: CallBackRights
;*
;* Purpose: Check .USR comment field for special callBACK string
;*
;* Input: None
;*
;* return: success if user has call back rights and 'cbnumber'
;* set to the number to be dialed.
;* FAILURE if user can't be called back.
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc CallBackRights
integer idx
find ucomment "CALLBACK[" idx
if found
idx = idx + 9
substr cbnumber ucomment idx 79
find cbnumber "]" idx
if found
strpoke cbnumber idx 0
strcpy savnum cbnumber
SETSUCCESS
return
endif
endif
SETFAILURE
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: WantsCB
;*
;* Purpose: Ask user if he wants to be called back.
;*
;* Input: None
;*
;* return: success if user wants to be called back
;* FAILURE otherwise
;*
;* Notes: If the user chooses hangup, the disconnect is done here.
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc WantsCB
string response, newnum
integer i
scroll 0 0 0 23 79 15
while forever ; loop until we break out
HOSTPUTS "`r`n`r`n Would you like to be called back at "
HOSTPUTS cbnumber
HOSTPUTS " ?`r`n"
HOSTPUTS " Your choice (Y=Yes, C=cancel)? "
HOSTGETC &response ; Get a character
if not success ; (If connection lost,
exitwhile ; break with FAILURE set)
endif ;
SETFAILURE ; Assume not calling back
strupr response ; Convert to upper case
switch response ; What do you want user?
case "Y" ; If 'Y'
SETSUCCESS ; change assumption
exitwhile ; and break
endcase ;
case "C" ; If 'C'
HOSTPUTS "`r`nNew number or CR to cancel: "
HOSTGETS &newnum 20 DISP ; see if new number for callback
strlen newnum i ; CR only pressed?
if i == 0 ; cancel if yes
strcpy cbnumber savnum ; make sure org number in place
SETFAILURE
exitwhile ; break
endif
strcpy cbnumber newnum ; get new number
loopwhile ; verify with user
endcase ;
endswitch
endwhile
endproc
;##########################################################################
;# #
;# ╔═══╗ #
;# ║ G.║ HIGH LEVEL I/O ROUTINES #
;# ╚═══╝ #
;# #
;# (1) GetUser #
;# (2) GetUserName #
;# (3) GetUserPswd #
;# (4) _HOSTGETs #
;# (5) _HOSTGETYN #
;# (6) _HOSTGETC #
;# (7) _HOSTPUTS #
;# #
;##########################################################################
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: GetUser
;*
;* Purpose: Wait for user to connect and login.
;*
;* Input: None
;*
;* return: Script aborts if ESC pressed. Otherwise, the function
;* won't return without a user.
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc GetUser
integer i
statmsg "Waiting for connection (ESC aborts)..."
TX "ATS0=1^M"
while forever
if N9 != F2 ; Look for keyhit if not local logon
if hitkey ; Allow ESC key to exit loop
XKEYGET &N9
endif
endif
if N9 == F2 ; Turn off answer and clear data
TX "ATS0=0^M" ; for local logon
pause 1
while comdata ; If data available at port
comgetc i ; get the next character
endwhile
endif
; The logic here is slightly different than the host mode login code.
; Since security is utmost, we won't let hackers know why they are
; being disconnected (because of an unknown name or an invalid
; password).
if connected || N9 == F2 ; Wait for Carrier Detect or local
HOSTCLS ; clear screen
statrest ; restore status line
call showintro ; say hello
call GetUserName ; Get the users name
if success
call GetUserPswd ; Get the users password
if success
call ParseUsrRec ; Find and parse user record
if success ; If found and parsed:
call CallBackRights ; see if user can be called back
if success
N8 = 1 ; ok to call back
endif
call sayhello
HOSTPUTS "`r`nCheck for mail...."
call ParseMail
if success
HOSTPUTS "`a You have new mail!"
pause 2
else
HOSTPUTS " No mail waiting"
pause 2
endif
SETSUCCESS
return ; return success
else
call toobad ; oh, not in password file
endif
endif
endif
N9 = 0 ; clear local flag
N8 = 0
HOSTHANGUP ; get em off
HOSTCLS
statmsg "Waiting for a connection (ESC aborts)..."
TX "ATS0=1^M" ; auto answer
endif
endwhile
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: GetUserName
;*
;* Purpose: Input a user name
;*
;* Input: None
;*
;* return: success if user name obtained
;* FAILURE if user not obtained
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc GetUserName
integer i, len, tries
tries = 0
if connected
pause 1
rflush
endif
while tries < 3
tries++
HOSTPUTS "`r`n`r`nFirst name: "
HOSTGETS &ufirst NAMEMAX DISP ; Get first (and optionally last)
if not success ; return FAILURE if CD drops
exitwhile
endif
strlen ufirst len ; len = length of first name
if len == 0 ; If length is zero
loopwhile ; go to top of loop
endif
find ufirst " " i ; Is there a last name? (SPACE)
if not found
find ufirst ";" i ; (Look for SEMICOLON if no SPACE)
endif
if found ; YES, there is a last name:
strpoke ufirst i 0 ; terminate the first name
i++ ; i -> 1st character in last name
substr ulast ufirst i 80 ; ulast is last name
else
HOSTPUTS "`r`n Last name: "
HOSTGETS &ulast NAMEMAX DISP ; Get last name
if not success ; return FAILURE if CD drops
exitwhile
endif
strlen ulast len
if len == 0
loopwhile
endif
endif
strupr ufirst
strupr ulast
S9 = ufirst
strcat S9 " "
strcat S9 ulast
NEWLINE
HOSTPUTS S9
HOSTPUTS "`r`nIs this correct (Y/N)? "
HOSTGETYN
if success
return
else ; if user says NO
tries-- ; don't count it as a try
endif
endwhile
HOSTHANGUP
SETFAILURE
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: GetUserPswd
;*
;* Purpose: Input a user password
;*
;* Input: None
;*
;* return: success if user password obtained
;* FAILURE if password not obtained
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc GetUserPswd
integer i, tries
tries = 0
NEWLINE
while tries < 3
HOSTPUTS "`r`nPassword: "
HOSTGETS &upassword PSWDMAX HIDE ; Get password
if not success
exitwhile
endif
strlen upassword i
if i > 0
strupr upassword
SETSUCCESS
return
endif
tries++
endwhile
HOSTHANGUP
SETFAILURE
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _HostGetS
;*
;* Purpose: Input a character string from the port or local keyboard
;*
;* Input: string parameter for return value
;*
;* return: If success, string variable contains the string
;* FAILURE if connection lost
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _HostGetS
strparm s
intparm max, dodisp
integer i
string response
strpoke s 0 0
i = 0
while forever
HOSTGETC &response
if not success
exitwhile
endif
switch response
case "`x01B" ; if user enters ESC
strpoke s 0 0x1B ; put it as first char
SETSUCCESS ; and exit
exitwhile
endcase
case "`r" ; hit the CR
SETSUCCESS
exitwhile
endcase
case "`b" ; backspace
if i != 0
HOSTPUTS response
i--
strpoke s i 0
endif
endcase
case " " ; This SPACE case must immediately
if i == 0 ; precede the default so it will
loopwhile ; fall through
endif
default
if i < max
if dodisp
HOSTPUTS response
else
HOSTPUTS "*"
endif
strcat s response
i++
endif
endcase
endswitch
endwhile
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _HostGetYN
;*
;* Purpose: Input a "Y" or a "N" response
;*
;* Input: None
;*
;* return: success if Yes
;* FAILURE if No or connection lost
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _HostGetYN
string response
while forever
HOSTGETC &response
if not success
return
endif
strupr response
switch response
case "Y"
SETSUCCESS
exitwhile
endcase
case "N"
SETFAILURE
exitwhile
endcase
endswitch
endwhile
HOSTPUTS response
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _HostGetC
;*
;* Purpose: Input a character from the port or local keyboard
;*
;* Input: string parameter for return value
;*
;* return: If success, string variable contains the character.
;* FAILURE is returned if the connection is lost.
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _HostGetC
strparm c
integer i
long loop = 36000
SETSUCCESS ; hope springs eternal
while loop != 0 ; time out for activity
if hitkey ; If a key is pressed
XKEYGET &i ; get the key
if chatdir == 1 ; user turn in chat mode
if i != 27 ; allow esc out of chat
loopwhile ; throw away key and continue
endif
endif
if i == F10 ; back door to chat mode
chatdir = 3 ; set sysop chat call
call dochat ; call chat mode
i = 13 ; set CR
exitwhile ; force screen to repaint
endif
exitwhile
endif
if comdata ; If data available at port
comgetc i ; get the next character
if chatdir == 2 ; sysop turn in chat mode
loopwhile ; throw away key and continue
endif
exitwhile
endif
loop--
endwhile
if N9 != F2
if not connected ; If carrier drops
SETFAILURE ; set error return code
return ; and return to caller
endif
endif
if loop == 0
HOSTPUTS "`a`r`n`r`nHost Time Out....."
HOSTGOODBYE
SETFAILURE
return
endif
key2ascii i c
SETSUCCESS
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _HostPutS
;*
;* Purpose: Output a string to the port and the local screen
;*
;* Input: string to output
;*
;* return: None
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _HostPutS
strparm s
integer c,idx
if connected ; don't send to modem unless connected
transmit s ; this causes problems if in local mode
endif
idx = 0
strpeek s idx c ; loop through and write chars to local screen
while c
writec c
idx++
strpeek s idx c
endwhile
endproc
;##########################################################################
;# #
;# ╔═══╗ #
;# ║ H.║ MISCELLANEOUS ROUTINES #
;# ╚═══╝ #
;# #
;# (1) ParseUsrRec #
;# (2) _BoxMsg #
;# (3) _CopySFld #
;# (4) _HostHangup #
;# (5) _Hostgoodbye #
;# (6) _QPause #
;# (7) _SetFailure #
;# (8) _SetSuccess #
;# (9) _XKeyGet #
;# #
;##########################################################################
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: ParseUsrRec
;*
;* Purpose: Lookup user in .USR file and parse record into globals
;*
;* Input: S9 is the name of the user to lookup
;*
;* return: success if user found and parsed.
;* FAILURE if user not found or error parsing record.
;*
;* Notes: These variables are initialized:
;* N0 - User's access level (0 - 9)
;* ucomment - User's comment field
;* ufirst - User's first name
;* ulast - User's last name
;* S9 - User's full name (first and last)
;* upassword - User's password
;* urec - Raw record (terminated with a line feed)
;*
;* .USR record:
;* lastname;firstname;password;n;comment.......
;* (n is the access level {'0','1',or '2'})
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc ParseUsrRec
integer i
string tmp, upswd
find S9 " " i ; i = index of blank name separator
strcpy ufirst S9 i ; copy first name
i++ ; i = index of last name
substr ulast S9 i 79 ; extract last name
strfmt tmp "%s;%s;" ulast ufirst ; 'tmp' is what we're looking for
strlen tmp i ; i = length of name part
fopen 1 HOSTUSRFILE "rt" ; Try to open user file
if success ; If opened
while not EOF 1 ; loop until end of file
fgets 1 urec ; Get record
strcmp urec tmp i ; Scan record for user
if success ; If this is our guy,
COPYSFLD &upswd urec &i FLD_SEP ; Copy password
COPYSFLD &ulevel urec &i FLD_SEP ; Copy access level
COPYSFLD &ucomment urec &i FLD_SEP ; Copy comment
strcmp upassword upswd ; valid password ?
if success
atoi ulevel N0 ; set user level to universal int
fclose 1
SETSUCCESS
return ; exit
endif
endif
endwhile
else
BOXMSG "Error opening user file."
endif
fclose 1
SETFAILURE
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _BoxMsg
;*
;* Purpose: Display a string in a box, wait for a key, restore screen
;*
;* Input: The string to display
;*
;* return: Nothing
;*
;* Notes: This routine can easily be modified to support multiple
;* line messages.
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
define COLOR 112 ; Box color
define TOPLINE 2 ; Row for top of box
define HPAD 3 ; Extra space around string (horizontal padding)
define VPAD 1 ; Extra lines above and below string
proc _BoxMsg
strparm s
integer len,toprow,botrow,leftcol,rightcol,bxkey
strlen s len
if len < 18
len = 18 ; Make sure we have room for Press any key msg
endif
vidsave 0
toprow = TOPLINE
botrow = toprow + 2 + 2*VPAD
leftcol = (80-len)/2 - (HPAD+1)
rightcol = leftcol+len+2*HPAD+1
box toprow leftcol botrow rightcol COLOR
toprow = toprow + VPAD + 1
leftcol = leftcol + HPAD + 1
atsay toprow leftcol COLOR s
atsay botrow leftcol COLOR " Press any key... "
leftcol = leftcol + 17
locate botrow leftcol
XKEYGET &bxkey ; get a key
SETFAILURE
vidrest 0
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _CopySFld
;*
;* Purpose: Copy a string field (SFLD) from any position within
;* the source string, to the destination string. Also,
;* increment the index by the length of the field copied.
;*
;* Input: (&destination,source,&index,field_separator)
;*
;* return: destination and int are updated.
;*
;* Notes: Terminates when a field_separator or line feed is encountered.
;* (If neither is encountered, the rest of the field is copied.)
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _CopySFld
strparm dst
strparm src
intparm index
intparm fldsep
integer newidx
string endstr,tmp
substr endstr src index 79 ; copy end of string to local var
key2ascii fldsep tmp ; tmp = field separator as a string
find endstr tmp newidx ; see if a separator is in the string
if not found ; If separator not found:
find endstr "\n" newidx ; is a line feed in the string?
if not found ; If not:
strlen endstr newidx ; use the whole string
endif ;
endif ;
strcpy dst endstr newidx ; copy field
index = index + newidx + 1 ; set caller's index
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _HostHangup
;*
;* Purpose: hangup the modem (try several times)
;*
;* Input: ('cbnumber' contains the number to dial)
;*
;* return: Nothing
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _HostHangup
integer hanguptries=3
if not connected
return
endif
while hanguptries--
pause 1
hangup
if not connected
exitwhile
endif
endwhile
if connected
HOSTPUTS "`r`n`r`nERROR: Unable to hangup.`r`n"
endif
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _HostGoodbye
;*
;* Purpose: Give goodbye message, pause, and hangup line
;*
;* Input: None
;*
;* return: None
;*
;* Notes:
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _HostGoodbye
HOSTPUTS "`r`n`r`n`r`ngoodbye "
HOSTPUTS S9
HOSTPUTS ".`r`n`r`nThanks for calling!`r`n`r`n"
HOSTPUTS "Your logoff time is "
HOSTPUTS $TIME0
HOSTPUTS " on "
HOSTPUTS $DATE
HOSTPUTS "`r`n`r`n(Please hangup now)`r`n`r`n`r`n"
N9 = 0
HOSTHANGUP
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _QPause
;*
;* Purpose: Pause a little and display a progress dot.
;*
;* Input: None
;*
;* return: None
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _QPause
termwrt '.'
mspause 300
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _SetFailure
;*
;* Purpose: set FAILURE to TRUE (same as success not TRUE)
;*
;* Input: None
;*
;* return: None
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _SetFailure
strcmp "X" ""
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _SetSuccess
;*
;* Purpose: set success to TRUE (same as FAILURE not TRUE)
;*
;* Input: None
;*
;* return: None
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _SetSuccess
strcmp "" ""
endproc
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;*
;* Function: _XKeyGet
;*
;* Purpose: Pause until a key is pressed and exit script if ESC
;*
;* Input: None
;*
;* return: None
;*
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
proc _XKeyGet
intparm key
keyget key
if (key==27)
if escok
return
endif
message "^M^J^M^JScript Aborted.^M^J"
TX "ATS0=0^M"
QPAUSE
exit
endif
if (key==0x0E08) ; convert backspace
key = 8
endif
endproc
proc showintro
string displine
fopen 0 "myhost.one" "rt"
if success
while not EOF 0
fgets 0 displine
HOSTPUTS displine
NEWLINE
endwhile
NEWLINE
fclose 0
endif
SETSUCCESS
endproc
proc sayhello
HOSTPUTS "`r`n`r`n`Hello "
HOSTPUTS S9
HOSTPUTS ", glad your back! Your logon is at "
HOSTPUTS $TIME0
HOSTPUTS " on "
HOSTPUTS $DATE
HOSTPUTS "`r`n`r`n"
endproc
proc domystuff
string response
while forever ; loop until we break out
call showmenu with &response
if not success ; (If connection lost,
exitwhile ; break with FAILURE set)
endif ;
strupr response ; Convert to upper case
HOSTPUTS response
switch response ; What do you want user?
; case "1" ; If '1'
; host ; enter host mode
; if not success ; this is a back door for now
; exitwhile
; endif
; endcase ;
case "O" ; other menu
call gamemenu
if not success
exitwhile
endif
endcase
case "F"
chdir "g:\oldzips"
call filetransfer
if not success
exitwhile
endif
endcase
case "M"
call mailmenu with &response
if not success
exitwhile
endif
switch response
case "R"
call ParseMail
if success
call getmail
if not success
exitwhile
endif
else
HOSTPUTS "`r`nYou have no mail"
endif
endcase
case "S"
call sendmail
if not success
exitwhile
endif
endcase
endswitch
endcase
case "S" ; dos shell
if N0 > 1 ; check user level
set keys off
set rxdata off
chdir PROCOMMDIR
if N9 == F2
shell
else
run "DOORWAY COM2 /S:* /I:DOSWAY /G:ON /V:B^U /C:DOS"
endif
set keys on
set rxdata on
else
HOSTPUTS "`r`ninvalid selection!!!"
endif
endcase
case "H"
call helpme
if not success
exitwhile
endif
endcase
case "T"
call dochat
if not success
exitwhile
endif
statrest
endcase
case "C" ; user may want a call back
if N8 == 1 ; make sure user didn't sneak in here
call WantsCB ; make sure
if success
call CallBack ; try to call back
if connected ; if user on line
loopwhile ; continue as normal
endif
endif
endif
endcase
case "K"
if N0 > 8
HOSTGOODBYE
quit
endif
endcase
case "G" ; If 'G'
return ; break
endcase ;
default
HOSTPUTS "`a"
loopwhile
endcase ;
endswitch
endwhile
endproc
proc showmenu
strparm response
NEWLINE
HOSTPUTS "`r`nO) Other Menu"
HOSTPUTS "`r`nF) File Transfer"
if N0 > 1
HOSTPUTS "`r`nS) Dos Shell"
HOSTPUTS "`r`nC) Call you back"
HOSTPUTS "`r`nM) Mail Box"
endif
if N0 > 8
HOSTPUTS "`r`nK) Quit Procomm Plus (Kill)"
endif
HOSTPUTS "`r`nT) Talk with SYSOP"
HOSTPUTS "`r`nH) Help"
HOSTPUTS "`r`nG) Goodbye - Hangup for now"
HOSTPUTS "`r`n`r`nSelection: "
HOSTGETC &response
endproc
proc gamemenu
string dum
NEWLINE
HOSTPUTS "`r`nNo games at this time"
HOSTPUTS "`r`nPress any key "
HOSTGETC &dum
endproc
proc toobad
HOSTPUTS "`r`n`r`n`a`a`a"
HOSTPUTS "`r`nYou are not in the system Log"
HOSTPUTS "`r`nTry again or contact me by voice."
HOSTPUTS "`a`a"
pause 3
endproc
proc mailmenu
strparm response
NEWLINE
HOSTPUTS "`r`nR) Read mail"
HOSTPUTS "`r`nS) Send mail"
HOSTPUTS "`r`n`r`nSelection: "
HOSTGETC &response
endproc
proc transmenu
strparm response
NEWLINE
HOSTPUTS "`r`nS) Send a file"
HOSTPUTS "`r`nR) Receive a file"
HOSTPUTS "`r`nD) View Directory"
if N0 > 1
HOSTPUTS "`r`nC) Change Directory"
endif
HOSTPUTS "`r`nE) Exit Menu"
HOSTPUTS "`r`n`r`nSelection: "
HOSTGETC &response
endproc
proc tchoice
strparm response
NEWLINE
HOSTPUTS "`r`nX) Xmodem"
HOSTPUTS "`r`n Z) Zmodem"
HOSTPUTS "`r`n Y) Ymodem"
HOSTPUTS "`r`n G) Ymodem-G"
HOSTPUTS "`r`n S) Sealink"
HOSTPUTS "`r`n A) Ascii"
HOSTPUTS "`r`n T) Telink"
HOSTPUTS "`r`n C) Cancel"
HOSTPUTS "`r`nSelect transfer method "
HOSTGETC &response
endproc
proc filetransfer
string response, curdir, newdirectory
while forever
call transmenu with &response
if not success ; (If connection lost,
exitwhile ; break with FAILURE set)
endif ;
strupr response ; Convert to upper case
HOSTPUTS response
switch response ; What do you want user?
case "S" ; If '1'
call movefile with 0
if not success
exitwhile
endif
endcase ;
case "R" ; attempt to call dos game
call movefile with 1
if not success
exitwhile
endif
endcase
case "D"
call showdir
if not success
exitwhile
endif
endcase
case "C"
getdir 0 curdir
HOSTPUTS "`r`nCurrent directory "
HOSTPUTS curdir
HOSTPUTS "`r`n"
HOSTPUTS "New Directory: "
HOSTGETS &newdirectory 60 DISP
if not success
exitwhile
endif
chdir newdirectory
if not success
HOSTPUTS "`r`n`r`n`aInvalid Directory"
pause 1
endif
endcase
case "E" ; If '3'
return ; break
endcase ;
default
HOSTPUTS "`a"
loopwhile
endcase ;
endswitch
endwhile
endproc
proc movefile
intparm xfer
string choice, fname
integer i
while forever ; transfer until you get tired
if xfer == 0
HOSTPUTS "`r`n`r`n(CR to Cancel) File Name you're sending: "
else
HOSTPUTS "`r`n`r`n(CR to Cancel) File Name you're receiving: "
endif
HOSTGETS &fname 12 DISP
if not success
exitwhile
endif
strlen fname i ; if only CR hit
if i == 0 ; we abort operation
return
endif
if xfer != 0 ; if getting a file
isfile fname ; it needs to be here
else
SETSUCCESS ; always ok if sending
endif
if success
call tchoice with &choice
if not success ; (If connection lost,
exitwhile ; break with FAILURE set)
endif ;
strupr choice ; Convert to upper case
HOSTPUTS choice
strcmp choice "C"
if not success
HOSTPUTS "`r`n`r`nStart your procedure.."
pause 1
endif
switch choice ; What do you want user?
case "X" ; xmodem
if xfer == 0
getfile xmodem fname
else
sendfile xmodem fname
endif
endcase
case "Z" ; zmodem
if xfer == 0
getfile zmodem
else
sendfile zmodem fname
endif
endcase
case "Y" ; ymodem batch
if xfer == 0
getfile ymodem
else
sendfile ymodem fname
endif
endcase
case "G" ; ymodem-g
if xfer == 0
getfile ymodemg
else
sendfile ymodemg fname
endif
endcase
case "S" ; sealink
if xfer == 0
getfile sealink
else
sendfile sealink fname
endif
endcase
case "A" ; ascii (who'd use this ?)
if xfer == 0
getfile ascii fname
else
sendfile ascii fname
endif
endcase
case "T" ; telink
if xfer == 0
getfile telink
else
sendfile telink fname
endif
endcase
case "C" ; cancel - go back
return
endcase
case "default" ; can't you read???
HOSTPUTS "`a"
loopwhile
endcase
endswitch
else
HOSTPUTS "`r`nFile not found" ; dummy!!
endif
while comdata ; If data available at port
comgetc i ; get the next character
endwhile
endwhile
endproc
proc showdir
string response,fname,dirline
integer linecount=0
integer another=0
integer nextcol=0
HOSTPUTS "`a`r`nPress Q to stop listing.."
HOSTPUTS "Press any key to begin"
HOSTGETC &response
if not success
return
endif
strupr response
strcmp response "Q"
if success
return
endif
NEWLINE
findfirst "*.*"
if found
another=1
strfmt dirline "%12s %8u " $FILENAME $FSIZE
nextcol++
endif
while another
findnext
if found
strfmt fname "%12s %8u " $FILENAME $FSIZE
if nextcol > 0
strcat dirline fname
HOSTPUTS dirline
NEWLINE
linecount++
nextcol=0
else
strcpy dirline fname
nextcol++
endif
if linecount >= 22
HOSTPUTS "`r`nPress any key for more (Q to quit)"
HOSTGETC &response
if not success
return
endif
strupr response
strcmp response "Q"
if success
return
endif
NEWLINE
linecount=0
endif
else
if nextcol == 0
HOSTPUTS dirline
NEWLINE
endif
another=0
endif
endwhile
HOSTPUTS "`r`nPress any key to return"
HOSTGETC &response
endproc
proc dochat
string verbage
integer paging = 30
integer keykey
HOSTPUTS "`r`n`r`nPaging SYSOP....30 seconds...."
HOSTPUTS "Press ESC to cancel"
escok=1 ; allow host to press esc with no exit
if chatdir != 3 ; regular chat call
while paging > 0
sound 440 50
if comdata
comgetc keykey
if keykey == 27
escok=0 ; reset esc flag
SETSUCCESS
return
endif
endif
if hitkey ; Allow ESC key to exit loop
XKEYGET &keykey
exitwhile
endif
endwhile
if paging < 0
HOSTPUTS "`r`nSYSOP not available`r`n"
escok=0 ; reflag esc key for host
SETSUCCESS
return
endif
HOSTPUTS "`a`r`n`r`nSYSOP waiting`r`n`r`n"
chatdir = 1 ; set user's turn to talk
endif
while forever
if chatdir == 3 ; if call came from sysop
HOSTPUTS "`a`a" ; signal user
chatdir = 2 ; set sysop turn
endif
if chatdir == 2
HOSTPUTS "`r`nSYSOP:`r`n" ; let user know sysop talking
else
HOSTPUTS "`r`nUSER:`r`n" ; let user know it's his turn
endif
HOSTGETS &verbage 80 DISP ; get users message
NEWLINE ; send \n
if not success
return
endif
strpeek verbage 0 keykey ; check for ESC
if keykey == 27 ; if sent
escok=0 ; reflag esc key for host script exit
chatdir = 0 ; allow all key strokes
SETSUCCESS ; exit chat
return
endif
if chatdir == 2 ; if sysop talked
chatdir = 1 ; it's user's turn
else ; else
chatdir = 2 ; it's sysop's turn
endif
endwhile
endproc
proc mkvattr
intparm attrvar, foreground, background, blinking
attrvar = (background << 4) | foreground | blinking
endproc
proc helpme
string helpline, response
integer haltme
fopen 1 "help.dat" "rt"
if not success
HOSTPUTS "`r`nHelp file not found`r`n"
pause 2
SETSUCCESS
return
endif
HOSTPUTS "`r`n`r`n"
while not EOF 1
fgets 1 helpline
strpeek helpline 0 haltme
if haltme == FLD_SEP
HOSTPUTS "Press any key to continue, Q to quit"
HOSTGETC &response
if not success
return
endif
strupr response
strcmp response "Q"
if success
fclose 1
SETSUCCESS
return
endif
HOSTPUTS "`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b`b"
HOSTPUTS "`b`b`b`b`b`b"
loopwhile
endif
HOSTPUTS helpline
NEWLINE
endwhile
HOSTPUTS "Press any key to return (END OF HELP)"
HOSTGETC &response
if not success
return
endif
NEWLINE
fclose 1
SETSUCCESS
endproc
proc ParseMail
integer i
string tmp
find S9 " " i ; i = index of blank name separator
strcpy ufirst S9 i ; copy first name
i++ ; i = index of last name
substr ulast S9 i 79 ; extract last name
strfmt tmp "%s %s;" ufirst ulast ; 'tmp' is what we're looking for
strlen tmp i ; i = length of name part
fopen 1 "hostmail.hdr" "rt" ; Try to open user file
if success ; If opened
while not EOF 1 ; loop until end of file
fgets 1 urec ; Get record
strcmp urec tmp i ; Scan record for user
if success ; If this is our guy,
fclose 1
SETSUCCESS
return ; exit
endif
endwhile
endif
SETFAILURE
endproc
proc getmail
integer i, sequence=1
integer delflag, index
string tmp, moveit
find S9 " " i ; i = index of blank name separator
strcpy ufirst S9 i ; copy first name
i++ ; i = index of last name
substr ulast S9 i 79 ; extract last name
strfmt tmp "%s %s;" ufirst ulast ; 'tmp' is what we're looking for
fopen 0 "hostmail.hdr" "rt" ; Try to open user file
if success ; If opened
while not EOF 0 ; loop until end of file
strlen tmp i ; i = length of name part
fgets 0 urec ; Get record
strcmp urec tmp i ; Scan record for user
if success ; If this is our guy,
COPYSFLD &mailfrom urec &i FLD_SEP ; Copy from name
COPYSFLD &maildate urec &i FLD_SEP ; Copy mail date
COPYSFLD &mailfile urec &i FLD_SEP ; Copy mail file
delflag = 0
call showmail with sequence, &delflag
if delflag ; ok this is kinda messy
fopen 2 "tempfile" "wt"
fseek 0 0 0 ; go to beginning of file
index = 1
while not EOF 0
fgets 0 moveit ; get next record
if index != sequence ; is this the one deleted
fputs 2 moveit ; if not put it in new file
endif
index++ ; next record number
endwhile
fclose 0 ; close files
fclose 2
delete "hostmail.hdr" ; delete current file
rename "tempfile" "hostmail.hdr" ; make new file the header
fopen 0 "hostmail.hdr" "rt" ; open header file
index = 1 ; reset index
while index != sequence ; find next record to read
fgets 0 moveit
index++
endwhile
HOSTPUTS "`amessage deleted"
loopwhile
endif
sequence++
endif
endwhile
else
BOXMSG "Error opening user file."
endif
fclose 0
SETSUCCESS
endproc
proc showmail
intparm sequence, delflag
string mailline, msgnum
fopen 1 mailfile "rt"
if not success
HOSTPUTS "`r`n`r`nError opening mail file -> "
HOSTPUTS mailfile
NEWLINE
pause 2
return
endif
strfmt msgnum "Message number: %d`r`n" sequence
HOSTPUTS "`r`n`r`n"
HOSTPUTS msgnum
HOSTPUTS "From : "
HOSTPUTS mailfrom
NEWLINE
HOSTPUTS "Date : "
HOSTPUTS maildate
HOSTPUTS "`r`n`r`n"
while not EOF 1
fgets 1 mailline
HOSTPUTS mailline
NEWLINE
endwhile
fclose 1
HOSTPUTS "End of Message (Delete Y/N) "
HOSTGETYN
if success
delflag = 1
delete mailfile
endif
NEWLINE
SETSUCCESS
endproc
proc sendmail
string sendto, msgline, filename, part1, part2, part3, part4
integer len
integer index=1
HOSTPUTS "`r`none moment....."
substr part1 $date 6 2
substr part2 $date 3 2
substr part3 $date 0 2
part4 = "00"
filename = part1
strcat filename part2
strcat filename part3
strcat filename part4
strcat filename ".mal"
while forever
isfile filename
if success
itoa index part4
strlen part4 len
if len == 1
strupdt filename part4 7 len
else
strupdt filename part4 6 len
endif
else
exitwhile
endif
index++
if index > 99
HOSTPUTS "`r`nmsgline limit exceeded`a`r`n"
SETSUCCESS
return
endif
endwhile
fopen 0 filename "wt"
fopen 1 "hostmail.hdr" "a"
if not success
fopen 1 "hostmail.hdr" "wt"
endif
escok=1
HOSTPUTS "`r`nYou may press ESC at anytime to exit this routine`r`n`r`n"
HOSTPUTS "`r`n`r`nMessgae to: "
HOSTGETS &sendto 80 DISP
call checkesc with sendto
if success
fclose 0
fclose 1
delete filename
escok=0
SETSUCCESS
return
endif
strupr sendto
strlen sendto len
for index=1 upto len
HOSTPUTS "`b"
endfor
HOSTPUTS sendto
NEWLINE
strfmt part1 "%s;%s;%s;%s`n" sendto,S9,$DATE,filename
index = 1
while forever
strfmt part2 "%d: " index
HOSTPUTS part2
HOSTGETS &msgline 76 DISP
call checkesc with msgline
if success
strfmt part3 "`r`nSend this message to %s (Y/N) " sendto
HOSTPUTS part3
HOSTGETYN
if success
fputs 1 part1
fclose 1
fclose 0
HOSTPUTS "`r`nmessage sent"
escok=0
SETSUCCESS
return
endif
else
strcat msgline "`n"
fputs 0 msgline
NEWLINE
endif
index++
endwhile
endproc
proc checkesc
strparm astring
integer isesc
strpeek astring 0 isesc
if isesc == 27
SETSUCCESS
else
SETFAILURE
endif
endproc
proc _newline
HOSTPUTS "`r`n"
endproc
proc _hostcls
integer loop
for loop=0 upto 25
HOSTPUTS "`n"
endfor
HOSTPUTS "`r"
endproc